
import net.optix.ip.model.ModelLocator;
[Bindable]
private var model:ModelLocator	=	ModelLocator.getInstance();

private function searchInventions(value:int):void
{
	model.inventions.filterFunction	=	filterInvention;
	model.inventions.refresh();
	switch(model.role)
	{
		case 1:
			model.clientInventions.filterFunction	=	filterInvention;
			model.clientInventions.refresh();
			break;
		case 3:
			model.firmInventions.filterFunction	=	filterInvention;
			model.firmInventions.refresh();
			break;
	}
}

private function filterInvention(item:Object):Boolean
{
	return filterClientDocket(item) && filterFirmDocket(item) && filterSerialNumber(item);
}

private function filterClientDocket(item:Object):Boolean
{
	var clientDocketValue:String	=	clientDocket.text.toLowerCase();
	
	var clientDocketS:String=	item.docket.toLowerCase();
	
	return clientDocketS.indexOf(clientDocketValue)>=0;
}

private function filterFirmDocket(item:Object):Boolean
{
	var firmDocketValue:String	=	firmDocket.text.toLowerCase();
	
	var firmDocketS:String=	item.firmDocket.toLowerCase();
	
	return firmDocketS.indexOf(firmDocketValue)>=0;
}

private function filterSerialNumber(item:Object):Boolean
{
	var serialNumberValue:String	=	serialNumber.text.toLowerCase();
	
	var serialNumberS:String=	item.applicationNumber.toLowerCase();
	return serialNumberS.indexOf(serialNumberValue)>=0;
}